﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nage.Algorithms.Population;
using Nage.Algorithms.Solution;
using Nage.Algorithms.Stop;
using Nage.Algorithms.Evolution;

namespace Nage.Algorithms
{
    /// <summary>
    /// Genetic algorithm interface
    /// </summary>
    /// <typeparam name="TSol">Type of the solution</typeparam>
    public interface IGeneticAlgorithm<TSol> where TSol : ISolution
    {
        /// <summary>
        /// Fired when each generation step has been completed
        /// </summary>
        event Action<IPopulation<TSol>> StepCompleted;

        /// <summary>
        /// Population Factory
        /// </summary>
        IPopulationFactory<TSol> PopulationFactory { get; set; }

        /// <summary>
        /// Solution Evaluator
        /// </summary>
        ISolutionEvaluator<TSol> SolutionEvaluator { get; set; }

        /// <summary>
        /// Stop Condition
        /// </summary>
        IStopCondition StopCondition { get; set; }

        /// <summary>
        /// Evolution
        /// </summary>
        IEvolution<TSol> Evolution { get; set; }
        
        /// <summary>
        /// Starts to compute the genetic algorithm
        /// </summary>
        /// <returns>Final population</returns>
        IPopulation<TSol> Solve();
    }
}
